var OrderCostGlassesForm = function () {
  var template = /*html*/ `
    <div class="order-cost-glasses-form" v-loading="loading" style="padding:0 10px 5px">
      <div style="margin-bottom:10px">
        <el-button size="medium" type="primary" @click="exportExcel">导出Excel</el-button>
      </div>
      <div>
        <el-table fit stripe border ref="orderTable" :data="orderLineDetailList" >
          <el-table-column prop="orderId" label="订单编号" min-width="140px" header-align="center"></el-table-column>
          <el-table-column prop="lineNo" label="订单序号" min-width="75px" align="center">
            <template slot-scope="scope">
              <span>{{scope.row.lineNo==='-1'?globalConfig.orderDefaultRowIndex:scope.row.lineNo}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="materialType" label="物料类型" min-width="100px" header-align="center"></el-table-column>
          <el-table-column prop="feedTotalDetail" label="订单投料数" min-width="100px" align="center"></el-table-column>
          <el-table-column prop="feedCountDetail" label="物料用料数" min-width="100px" align="center"></el-table-column>
          <el-table-column prop="unitPrice" label="物料单价" min-width="100px" align="center"></el-table-column>
          <el-table-column prop="glassesMoney" label="每副成本" min-width="100px" align="center"></el-table-column>
          <el-table-column prop="orderTotalDetail" label="订单数" min-width="100px" align="center"></el-table-column>
          <el-table-column prop="glassesOrderMoney" label="订单成本" min-width="100px" align="center"></el-table-column>
        </el-table>
      </div>
    </div> 
   `;
  return {
    props: {
      orderLineDetail: {
        type: Object,
        required: true
      }
    },
    data: function () {
      return {
        loading: false,
        //返回的请求数据list
        orderLineDetailList: []
      }
    },
    created: function () {
      this.getOrderLineDetailList();
    },
    methods: {
      getOrderLineDetailList: function () {
        var orderLineDetail = this.orderLineDetail;
        this.loading = true;
        var self = this;
        ajaxRequest("orderCostFlasses/getOrderLineDetailList", orderLineDetail).then(function (res) {
          self.orderLineDetailList = res;
          self.loading = false;
        }).catch(function () {
          self.loading = false;
        });
      },

      exportExcel: function () {
        var $el = $(this.$refs['orderTable'].$el);
        var $table = $el.find('.el-table__header-wrapper table tr,.el-table__body-wrapper table tr');
        export_table_to_excel($table, '订单成本明细', {
          sheetName: '订单成本明细',
          tableTitle: {
            value: "订单成本明细",
            fontSize: 18,
            colspan: 9,
            align: "center"
          },
          colWidth: [145, 80, 235, 140, 140, 140, 140, 140, 140]
        });
      }
    },
    template: template
  }

}();
